﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SprentCMS.Core.Models.ViewDatas;

namespace SprentCMS.Web.Controllers
{
    [HandleError]
    public class HomeController : BaseController
    {
        public ActionResult Index()
        {
            BaseModuleViewData vd = new BaseModuleViewData()
            {
                CurrentMenuItem = "Home",
                Modules = new Dictionary<string, List<ModuleBase>>(),
            };
            vd.Modules.Add("user1",
                new List<ModuleBase>() {
                    new ModuleBase(){ 
                        Id=0, ModuleName="user1"} 
                });

            Module_CustomHTML customHTML = new Module_CustomHTML()
            {
                Id = 1,
                Description = "xxx",
                Enabled = true,
                Menus = "0",
                ModuleName = "custom_html",
                ModuleType = "Moudle_CustomHTML",
                Position = "user2",
                HTML = "Hi",
                Title = "用户自定义标题 1",
                ShowTitle = true,
                BeginHTML = "<font color=\"red\">",
                EndHtml = "</font>"
            };
            vd.Modules.Add("user2", new List<ModuleBase>() { customHTML });

            customHTML = new Module_CustomHTML()
            {
                Id = 2,
                Description = "xxx",
                Enabled = true,
                Menus = "0",
                ModuleName = "custom_html",
                ModuleType = "Moudle_CustomHTML",
                Position = "user2",
                HTML = "Hi",
                Title = "用户自定义标题 2",
                ShowTitle = true,
                BeginHTML = "<font color=\"green\">",
                EndHtml = "</font>"

            };
            vd.Modules["user2"].Add(customHTML);

            Module_NewsList newsList = new Module_NewsList()
            {
                Id = 2,
                Description = "xx",
                Enabled = true,
                Menus = "0",
                ModuleName = "news_list",
                ModuleType = "Module_NewsList",
                Position = "user3",
                ShowTitle = true,
                Title = "新闻列表"
            };
            newsList.NewsList = new PagedList<string>(
                new List<string>() { "新闻1", "新闻2", "新闻3" },
                1, 20, 20, 0);

            vd.Modules.Add("user3", new List<ModuleBase>() { newsList });

            return View(vd);
        }
    }
}
